//
//  GQJCompareModel.m
//  TotalDemo
//
//  Created by gujian on 16/8/2.
//  Copyright © 2016年 gujian. All rights reserved.
//

#import "GQJCompareModel.h"



@implementation GQJCompareModel


- (instancetype)initWithName:(NSString *)name age:(NSUInteger)age
{
    self = [super init];
    
    if (self) {
        
        _name = name;
        _age = age;
    }
    
    return self;

}

- (NSString *)description
{
    return [NSString stringWithFormat:@"name:%@，age:%@，Pointer:%p",_name,@(_age),self];
}

- (NSComparisonResult)comparePerson:(id)compareModel
{
    if (![compareModel isKindOfClass:[GQJCompareModel class]])
        NSAssert(NO, @"不是GQJCompareModel类型数据");
    
    GQJCompareModel *otherCompareModel = (GQJCompareModel *)compareModel;
    
    NSComparisonResult result = [[NSNumber numberWithUnsignedInteger:_age] compare:[NSNumber numberWithUnsignedInteger:otherCompareModel.age]];
    if (result == NSOrderedSame) {
        result = [self.name compare:otherCompareModel.name];
    }
    
    return result;
}

- (void)logInfo
{
    NSLog(@"private methods");
}

@end
